import { defineStore } from 'pinia'
import axios from 'axios'
import { ref } from 'vue'

const api = axios.create({
  baseURL: 'http://localhost:5000/api',
  withCredentials: false,
  headers: {
    Accept: 'application/jsons',
    'Content-type': 'application/json',
  },
})

export const studentStore = defineStore('student', () => {
  // 定义数据
  const students = ref([])
  const token = 'xxxx'
  // 定义方法
  const getStudents = async () => {
    const response = await api.post('/student', {
      headers: {
        Authoriztion: `Bearer ${token}`,
      },
    })
    students.value = response.data
  }

  return {
    students,
    getStudents,
  }
})
